from django.db import models


class Collect(models.Model):
    # 药植物的唯一ID
    id = models.AutoField(primary_key=True ,verbose_name="药植物id") # 主键
    # 药植物标题
    name = models.CharField(max_length=20,verbose_name="药物名称")
    # 收集的摘要
    type = models.CharField(max_length=10,verbose_name="分类")
    # 经纬度
    location = models.CharField(max_length=100,verbose_name='经纬度')
    #地区
    province = models.CharField(max_length=55,verbose_name='省会')
    #城市
    city = models.CharField(max_length=55,verbose_name='城市')
    #图片
    photo = models.ImageField(verbose_name='照片', upload_to='IMG',max_length = 100)
    # 药植物的主要内容
    content = models.TextField(verbose_name="药植物作用")
    # 药植物的发布日期
    publish_date = models.DateTimeField(auto_now=True)
    #种植公顷
    value = models.IntegerField(verbose_name="药植物种植面积")
    #库存
    stock = models.IntegerField(verbose_name='药植物库存')

    class Meta:
        verbose_name = "数据库"
        verbose_name_plural = verbose_name

# 就是显示题目标题的函数
    def __str__(self):
        return self.name


class province(models.Model):
    name = models.CharField(max_length=55 ,verbose_name='省份名')
    value = models.IntegerField(verbose_name='每个省份的药植物数目')

    class Meta:
        verbose_name = "省份"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

class city(models.Model):
    name = models.CharField(max_length=55,verbose_name='城市名')
    value = models.IntegerField(verbose_name='每个城市的药植物数目')

    class Meta:
        verbose_name = "城市"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
# class origin(models.Model):
#     id = models.AutoField(primary_key=True, verbose_name="原产地")
#     name = models.CharField(max_length=20, verbose_name="源产地")
#     desc = models.CharField(max_length=10, verbose_name='描述')
#     city = models.CharField(max_length=10, verbose_name='城市名')
#     province = models.ForeignKey(Collect,max_length=30, verbose_name="省会")
#     value = models.BigIntegerField(verbose_name="本省的总标本数")
#
#     class Meta:
#         verbose_name = "原产地"
#         verbose_name_plural = verbose_name
#
#     # 就是显示题目标题的函数
#     def __str__(self):
#         return self.name